Skip to content

Conversation

@matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented Oct 20, 2025

Summary

This PR fixes an issue where default styles like text and background color were prioritised over custom inline content & styles.

This could be seen in the mentions inline content example, where, copying and pasting a mention would parse it as a background color style instead of a mention.

Closes #2064

Rationale

N/A

Changes

  • Added runsBefore to custom inline content and style implementations.
  • Made custom styles and inline content run before default content, including parse rules.
  • Removed old unused text and background color marks.
  • Made text and background color marks non-consuming, so other parse rules can still run on the same elements.

Impact

This PR should fix any potential issues that come from custom inline content and styles priority.

Testing

  • Changed Mention in the unit test schema to have backgroundColor inline style, to replicate the issue fixed in this PR.
  • Added unit test case for copying & copy/pasting Mention.
  • Updated snapshot for exporting Mention.

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

@vercel
Copy link

vercel bot commented Oct 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
blocknote Ready Ready Preview Oct 24, 2025 4:15pm
blocknote-website Ready Ready Preview Oct 24, 2025 4:15pm

@nperez0111 nperez0111 mentioned this pull request Oct 20, 2025
1 task
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 24, 2025

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@2119

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@2119

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@2119

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@2119

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@2119

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@2119

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@2119

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@2119

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@2119

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-email-exporter@2119

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@2119

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@2119

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@2119

commit: 3587fe7

"content": [
{
"styles": {
"backgroundColor": "transparent",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the "transparent"? or can we get rid of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, this is a result of us now being able to parse multiple styles from a single HTML element, as GDocs puts all text decorations into a single style attribute.

Right now, any style attribute on a span element with color/backgroundColor fields gets parsed as a TextColor/BackgroundColor style respectively, regardless of the value. I think it makes sense to filter out values like transparent or unset though, but this is out of scope for this PR - I think we should make a new issue for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewlipski can you make that issue since you've the most context on it?

executeTest: testCopyHTML,
},
{
testCase: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewlipski does this test also test pasting / parsing?

Are we confident the test that was added would have failed pre-fix? (and thus will catch potential regressions correctly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I reverted the other changes while keeping the test and it did indeed fail. It does also test copy/paste (the copy/paste equality tests also use the copy test cases).

It's not obvious but export/parse is also tested. We previously had tests for mentions, the reason they didn't catch this issue though was because the mentions were unstyled. After adding dom.style.backgroundColor = "red" to the mention DOM element in testSchema.ts, the export/parse equality test failed without the other changes from this PR.

@nperez0111 nperez0111 merged commit f1d6e89 into main Oct 29, 2025
12 checks passed
@nperez0111 nperez0111 deleted the mention-parse-priority-fix branch October 29, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag and drop with clear the inline content attribute

4 participants